<?php
include "conf.php";
include "php/functions.php";
$_DB = new PDO("mysql:host={$_MYSQL['host']};dbname={$_MYSQL['db_name']}", $_MYSQL['db_user'], $_MYSQL['password'],array(PDO::ATTR_PERSISTENT => true));
$_DB->query("SET CHARACTER SET 'utf8'");

if (isset($_REQUEST['email'])){
	$email=$_REQUEST['email'];
	$activationlink=fbappencode($email);
	
	//write to database
	if(!check_user_exists($email)) {
		$query=$_DB->prepare('INSERT INTO `user` (`fbid`,   `name`, `email`,  `sex`, `locale`, `hometown`,   `country`,  `birthday`,  `rights`,  `regdate`,  `authtoken`) VALUES( :fbid, :name ,:email, :sex, :locale, :hometown, :country, :birthday, :rights, :regdate, :authtoken )');
		$query->execute(array(
			'fbid'=>"",
			'name'=>$email,
			'email'=>$email,
			'sex'=>"",
			'locale'=>"",
			'hometown'=>"",
			'country'=>"",
			'birthday'=>date('Y-m-d H:i:s'),
			'rights'=> -1,
			'regdate'=>date('Y-m-d H:i:s'),
			'authtoken'=>$activationlink));
	}
	
	
	//send mail
	//
	echo "<a href='http://fbapp.rene-pickhardt.de/auth/email&code=".$activationlink."'>hier klicken</a>'";
	
	//display something meaningful or redirect to streaming app (best thing include facebook profile of in legend ask to become in legend fan or show pandemonium video and other promo tools (-:
}


?>